package com.firstgroup.dms.config;

import com.firstgroup.dms.interceptor.LoginHandlerInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class LoginInterceptorConfig implements WebMvcConfigurer {
	// 将登录拦截器配置到容器中
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(new LoginHandlerInterceptor())
				.addPathPatterns("/**")
				.excludePathPatterns(
						"/",
						"/login/login.html", // 登录页面
						"/user/login", // 登录接口
						"/user/logout", // 登出接口
						"/error", // 错误页面
						"/css/**",
						"/images/**",
						"/jquery/**",
						"/js/**",
						"/layui/**");
	}

	// 配置视图跳转
	@Override
	public void addViewControllers(ViewControllerRegistry registry) {
		// registry.addViewController("/").setViewName("index");
		// registry.addViewController("/index.html").setViewName("index");
	}
}